package com.sky.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


   @Configuration
   @Slf4j
   public class OssConfigConfiguration {

       @Value("${sky.alioss.endpoint}")
       private String endpoint;

       @Value("${sky.alioss.access-key-id}")
       private String accessKeyId;

       @Value("${sky.alioss.access-key-secret}")
       private String accessKeySecret;

       @Value("${sky.alioss.bucket-name}")
       private String bucketName;

       @Bean
       public OSS ossClient() {
           return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
       }

       @Bean
       public String ossBucketName() {
           return bucketName;
       }
   }